<gm:page title="Flugplätze" authenticate="false">


<script>
function filterAirports(suche){
  if(suche == "") {
 //   return;
  }
  var count = 0;
  var originalList = google.mashups.getObjectById('airportSRC');
  var displayList  = google.mashups.getObjectById('airports');
  var displayMap  = google.mashups.getObjectById('airportMap');
  var icaoGPATH = new GPath('atom:icao');
  var titleGPATH = new GPath('atom:title');
  var sumGPATH = new GPath('atom:summary');
  
  for (var i=0; i<displayList.getData().size(); i++) {
    displayList.getData().removeEntry(displayList.getData().entryAt(i));
  }
  
  suche = suche.toLowerCase();

  for (var i=0; i<originalList.getData().size(); i++) {
    var entry = originalList.getData().entryAt(i);
    var icao = icaoGPATH.getValue(entry);
    var title = titleGPATH.getValue(entry);
    var sum = sumGPATH.getValue(entry);
    if((title.toLowerCase().indexOf(suche) > -1) || (sum.toLowerCase().indexOf(suche) > -1) || (icao.toLowerCase().indexOf(suche) > -1)) {
      displayList.getData().addEntry(entry);
      count++;
    }
  }
  if(count == 0) {
//    alert("Leider kein Suchergebnis");
  } else {
//    displayList.selectEntry(displayList.getData().entryAt(0));
//    displayMap.selectEntry(displayList.getData().entryAt(0));
  }
}
</script>
  
  
<div class="gm-app-header">
<h1>Flugplätze</h1>
<input type="text" size="50" id="icaoInput" name="icaoInput" value="ICAO oder Stadt" /> 
<input type="button" value="Suchen!" onclick="filterAirports(document.getElementById('icaoInput').value)" /> 
</div>

<gm:list id="airports" template="tplAirports" pagesize="15" data="${tmp}/airports">
<gm:sort name="title" ref="atom:title" />
<gm:handleEvent src="airportMap" event="select" />
</gm:list>


<div style="margin-left: 300px">
<gm:map id="airportMap" infotemplate="airportMapDetailsTemplate" data="${airports}" latref="geo:lat" lngref="geo:long" maptypes="true"  width="700" height="500">
<gm:handleEvent src="airports"/>
</gm:map>
</div>

<gm:template id="tplAirports">
<table class="blue-theme" style="float: left; width: 250px;">
<tr><td colspan="3"><gm:pager /></td></tr>
<tr><td><gm:header sort="title">Kürzel</gm:header></td><td><gm:header sort="summary">Name</gm:header></td><td><gm:header sort="icao">ICAO</gm:header></td></tr>
<tr repeat="true"><td><gm:text ref="atom:title" /></td><td><gm:text ref="atom:summary" /></td><td><gm:text ref="atom:icao" /></td></tr>
<tr><td colspan="3"><gm:pager /></td></tr>
</table>
</gm:template>

<gm:template id="airportMapDetailsTemplate">
<table style="width:300px">
<tr><td><b><gm:text ref="atom:summary" /></b></td></tr>
</table>
</gm:template>

<gm:list id="airportSRC" template="hide" data="http://idkfa.dyndns.org/devel/airports/feed.php" />
<gm:template id="hide">
  <table style="visibility: hidden; display: none;">
    <tr repeat="true"><td><gm:text ref="atom:icao" /></td></tr>
  </table>
</gm:template>



<p style="clear: both; font-size: 0.8em">&copy; 2008 Christian Schmitt, christian (ät) idkfa (punkt) de</p>
</gm:page>